// 文章列表数据
import request from '@/utils/request.js';

export const getArticalList = (params) => {
  return request({
    method: 'GET',
    url: '/v1_1/articles',
    params: params,
  });
};

// 获取文章详情数据
export const getArticalDetails = (articalId) => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${articalId}`,
  });
};

// 关注用户
export const addFollow = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target,
    },
  });
};

// 取消关注用户
export const deleteFollow = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${target}`,
  });
};

// 收藏文章
export const collectArtical = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target,
    },
  });
};

// 取消收藏
export const cancelArtical = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${target}`,
  });
};

// 点赞文章
export const likeArtical = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target,
    },
  });
};

// 取消点赞文章
export const dislikeArtical = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${target}`,
  });
};
